package com.juc.executors.executors6;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

public class Run {
		/**
		 * newFixedThreadPool(int nThreads, ThreadFactory threadFactory) 
		   有界线程池中的Thread类可以有程序员自己自定义
		 *
		 */
	public static void main(String[] args) {
		MyThreadFactory threadFactory = new MyThreadFactory();
		ExecutorService executorService = Executors.newFixedThreadPool(2, threadFactory);
	    Runnable runnable = new Runnable() {
			
			@Override
			public void run() {
			    try {
					System.out.println(" begin 我在运行 " + System.currentTimeMillis() + " "+Thread.currentThread().getName());
					Thread.sleep(3000);
					System.out.println(" end 我在运行 " + System.currentTimeMillis() + " "+Thread.currentThread().getName());

				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		};
		executorService.execute(runnable);
		executorService.execute(runnable);
		executorService.execute(runnable);

	
	}
}
